﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>存货现存量信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
        <a title="数据明细" href="javascript:;" lay-event="view"><i class="layui-icon">&#xe615;</i></a>
       
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                       
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proName" placeholder="存货名称" autocomplete="off" class="layui-input" id="proName">
                            </div>
                            @*<div class="layui-inline layui-show-xs-block">
                                <input type="text" name="spec" placeholder="规格型号" autocomplete="off" class="layui-input" id="spec">
                            </div>*@
                      
                            <div class="layui-inline layui-show-xs-block">
                                <select id="wareHouse" name="wareHouse" class="wareHouse" lay-filter="wareHouse" lay-search>
                                    <option value="">选择仓库</option>
                                </select>
                            </div>
                      
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="userSearch" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>

                        </form>
                    </div>

                    <div class="layui-card-body" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    var currPage = 1;//首先默认值为1，防止出错
    function loadData() {
        var dUrl = "../Statistics/getDataList?dataType=pstock&condition="
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
                { field: 'proCode', align: 'center', title: '存货编码', width: '18%' }
                , { field: 'proName', align: 'center', title: '存货名称', width: '18%' }
                , { field: 'spec', align: 'center', title: '规格', width: '15%' }
                , { field: 'houseName', align: 'center', title: '所属仓库', width: '18%' }
                , { field: 'number', align: 'center', title: '主数量', width: '15%' }
                , { field: 'barCount', align: 'center', title: '件数', width: '11%' }
                , { field: 'right', align: 'center', title: '操作', toolbar: '#barDemo', width: '5%', fixed: 'right' }
            ]], done: function (res, curr, count) {
                currPage = curr;

            }
           //   , height: $(document).height() - $('#list').offset().top - 20
            , url: dUrl + conditon
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , limits: [20, 35, 50]
            , limit: 20 //每页默认显示的数量
            , id: "tData"
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event == 'view') {
                    OpenPage(data.proName + "（" + data.proCode + "）数据明细", "../Statistics/StockDetail?proCode=" + data.proCode + "&wareHouseName=" + wareHouse);
                }
             

            });

        });
    }

    $(function () {
        //获取列表
        wareInfo("wareHouse");
        CustomInfo();
        loadData();
    })
    var wareHouse = "";

    //layui.use('form', function () {
    //    var form = layui.form;
    //    form.on('select(wareHouse)', function (data) {
    //        wareHouse = $("#wareHouse option:selected").text();
    //        loadData();
    //    });
    //});


    function CustomInfo() {
        $.ajax({
            url: "../Statistics/StockCustomer",
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {
                if (data.Result) {
                    var datas = data.Data;
                    for (var i = 0; i < datas.length; i++) {
                        $(".customCode").append("<option value=\"" + datas[i]["customCode"] + "\" >" + datas[i]["customName"] + "</option>");
                    }

                }
            }
        });
    }
</script>